package zm.irc.weechat.pojo;

import java.util.HashMap;
import java.util.Map;

import zm.irc.util.JsonUtils;

public class WeechatMessage {
    
    private static final String MSG_TYPE_TEXT = "text";

    public static WeechatMessage build(){
        return new WeechatMessage();
    }

    public WeechatMessage toAllUser(){
        this.put("touser","@all");
        return this;
    }

    public WeechatMessage textType(){
        this.put("msgtype",MSG_TYPE_TEXT);
        return this;
    }

    public WeechatMessage agentId(Integer agentId){
        this.put("agentid",agentId);
        return this;
    }

    public WeechatMessage content(Object content){
        Map<String,Object> contentMap = new HashMap<>();
        contentMap.put("content",content);

        this.put(MSG_TYPE_TEXT,contentMap);
        return this;
    }

    private Map<String,Object> msg = new HashMap<>();

    private WeechatMessage(){
        this. msg = new HashMap<>();
    }

    private void put(String key,Object value){
        this.msg.put(key, value);

    }

    @Override
    public String toString() {
        return JsonUtils.beanToJson(this.msg);
    }

    

}
